package com.whfc.base.service.impl;


import com.whfc.base.dao.AppScheduleMapper;
import com.whfc.base.entity.AppSchedule;
import com.whfc.base.service.AppScheduleService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * 日程表(AppSchedule)表服务实现类
 *
 * @author makejava
 * @since 2022-08-01 11:59:40
 */
@DubboService(interfaceClass = AppScheduleService.class, version = "1.0.0")
public class AppScheduleServiceImpl implements AppScheduleService {
    @Resource
    private AppScheduleMapper appScheduleDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public AppSchedule queryById(Integer id) {
        return this.appScheduleDao.selectByPrimaryKey(id);
    }



    /**
     * 新增数据
     *
     * @param appSchedule 实例对象
     * @return 实例对象
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public AppSchedule insert(AppSchedule appSchedule) {
        this.appScheduleDao.insertSelective(appSchedule);
        return appSchedule;
    }

    /**
     * 修改数据
     *
     * @param appSchedule 实例对象
     * @return 实例对象
     */
    @Override
    public AppSchedule update(AppSchedule appSchedule) {
        this.appScheduleDao.updateByPrimaryKeySelective(appSchedule);
        return this.queryById(appSchedule.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        AppSchedule AppSchedule = this.queryById(id);
        AppSchedule.setDelFlag(1);
        int i = appScheduleDao.updateByPrimaryKeySelective(AppSchedule);
        return i > 0;
    }
}
